package cn.mini.mybatis.mybatis.session;

import cn.mini.mybatis.mybatis.builder.xml.XMLConfigBuilder;
import cn.mini.mybatis.mybatis.session.defaults.DefaultSqlSessionFactory;

import java.io.Reader;

public class SqlSessionFactoryBuilder {



    public SqlSessionFactory build(Reader reader) {
        try {
            XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(reader);
            return build(xmlConfigBuilder.parse());
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("Error building SqlSession.", e);
        }
    }


    public SqlSessionFactory build(Configuration configuration) {
        return new DefaultSqlSessionFactory(configuration);
    }

}
